package somospunto.servlet.supermercado;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import somospunto.negocio.ProductoNegocio;

/**
 * Servlet implementation class InsertarProductoServlet
 */
@WebServlet("/InsertarProductoServlet")
public class InsertarProductoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public InsertarProductoServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String nom_prod = request.getParameter("nom_prod");
		String mar_prod = request.getParameter("marca_prod");
		String cat_prod = request.getParameter("cat_prod");
		String cadena = request.getParameter("precio_prod");
		
		String est_prod = request.getParameter("est_prod");
		String des_prod = request.getParameter("des_prod");
		String ima_prod = request.getParameter("ima_prod");
		
		ProductoNegocio producto = new ProductoNegocio();
		try {
			producto.insertarProducto(nom_prod, mar_prod, cat_prod, cadena, est_prod, des_prod, ima_prod);
			request.setAttribute("MSG", "Gracias por registrarte");
			RequestDispatcher rd = request.getRequestDispatcher("/admin_super/productos2.jsp");
			rd.forward(request, response);
		} catch (Exception e) {
			String aasd= "asdada";
			// TODO: handle exception
		}
		
	}

}
